bitkeeper revision 1.1159.1.227 (416ca176osUUBQBGiZS4hIALhIyUsg)
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Wed, 13 Oct 2004 03:31:02 +0000 (03:31 +0000)
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Wed, 13 Oct 2004 03:31:02 +0000 (03:31 +0000)
Slightly smarter initial CPU placement.

xen/common/dom0_ops.c

index 5eb31b736c1ff75d96766194537203d398c9900e..829eb1de2ee9cf973066b61086bb65b1e81c95fa 100644 (file)
@@ -178,7 +178,29 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
             break;
 
         if ( op->u.createdomain.cpu == -1 )
-            pro = (unsigned int)dom % smp_num_cpus;
+       {
+           /* Do an initial placement. Fix me for hyperthreading! */
+           struct domain    *d;
+           int i, j=0, c[smp_num_cpus];
+           
+           pro=0; /* keep compiler happy */
+
+           for (i=0;i<smp_num_cpus;i++) 
+               c[i]=0;
+
+           for_each_domain ( d ) {
+               c[d->processor]++;
+               j++;
+           }
+
+           for (i=0;i<smp_num_cpus;i++) {
+               if( c[i]<j )
+               {
+                   j = c[i];
+                   pro = i;
+               }
+           }
+       }
         else
             pro = op->u.createdomain.cpu % smp_num_cpus;